package com.lazy.example.clientfault;

import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;

/**
 * Created by lazy on 7/12/16.
 */
public class ByteBufClientInitializer extends ChannelInitializer<SocketChannel> {
    private final ChannelHandler handler;

    public ByteBufClientInitializer(ChannelHandler handler){
        this.handler = handler;
    }

    @Override
    protected void initChannel(SocketChannel ch) throws Exception{
        ChannelPipeline p = ch.pipeline();
        // add service handler
        if (handler != null) {
            p.addLast(handler);
        }
    }
}
